<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--#include file="DataLoad.asp"-->
<%Call CheckAdmin2()%>
<html>
<head>
<title><%=GuildName%> - DKP系统</title>
<script language="JavaScript" src="inc/jquery.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Generator" content="EditPlus">
<meta name="Author" content="SULei">
<meta name="Keywords" content="DKP WOW GUILD">
<meta name="Description" content="">
<link href="<%=StylePath%>/main.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="<%=StylePath%>/styleplus.js"></script>
<style type="text/css" media="all">

</style>


</head>

<body>

<div class="header">
<!--#include file="menu.asp"-->
<script type=text/javascript>
function eventselectclass() {
	var sclass=document.forms["eventadd"].event_class.value
	if (sclass=="加入" || sclass=="离开")
	{
		document.forms["eventadd"].object.className="action"
		document.forms["eventadd"].object2.className="unuse"
		document.forms["eventadd"].event_dkp.className="unuse"
		document.forms["eventadd"].event_dkp2.className="unuse"
	}
	else if (sclass=="拾取")
	{
		document.forms["eventadd"].object.className="action"
		document.forms["eventadd"].object2.className="action"
		document.forms["eventadd"].event_dkp.className="action"
		document.forms["eventadd"].event_dkp2.className="action"
	}
	else if (sclass=="分解") {
		document.forms["eventadd"].object.className="unuse"
		document.forms["eventadd"].object2.className="action"
		document.forms["eventadd"].event_dkp.className="action"		
		document.forms["eventadd"].event_dkp2.className="unuse"
	}
	else if (sclass=="发现" || sclass=="首次" || sclass=="击杀") {
		document.forms["eventadd"].object.className="unuse"
		document.forms["eventadd"].object2.className="action"
		document.forms["eventadd"].event_dkp.className="action"		
		document.forms["eventadd"].event_dkp2.className="unuse"
	}
	else if (sclass=="职务任命") {
		document.forms["eventadd"].object.className="action"
		document.forms["eventadd"].object2.className="action"
		document.forms["eventadd"].event_dkp.className="action"
		document.forms["eventadd"].event_dkp2.className="unuse"
	}
	else if (sclass=="团队事件") {
		document.forms["eventadd"].object.className="unuse"
		document.forms["eventadd"].object2.className="action"
		document.forms["eventadd"].event_dkp.className="action"
		document.forms["eventadd"].event_dkp2.className="unuse"
	}
	else if (sclass=="个人事件") {
		document.forms["eventadd"].object.className="action"
		document.forms["eventadd"].object2.className="action"
		document.forms["eventadd"].event_dkp.className="action"
		document.forms["eventadd"].event_dkp2.className="unuse"
	}	else {
		document.forms["eventadd"].object.className="unuse"
		document.forms["eventadd"].object2.className="action"
		document.forms["eventadd"].event_dkp.className="action"		
		document.forms["eventadd"].event_dkp2.className="unuse"
	}}

var currentActiveTab = "menuB";

</script>
</div>
<div class="main">

			<%
			select case Request("action")
			case "step1sql"
			Call step1sql()
			case "add"
			call raidplan_addsql()
			case "del"
			call raidplan_delsql()
			case "collect"
			call raid_collect1()
			'默认列表未结束的活动
			case "collect2"
			call raid_collect2()
			case else
			call raid_list()
			end select
			%>
</div>
<div id="footer"><!--#include file="footer.asp"--></div>
</body>
</html>
<%
SUB raid_collect1()
	if not Isnumeric(Request("id")) then exit sub
	sql="select * from raid where id="&Request("id")
	rs.open sql,conn,1,1
		if rs.bof or rs.eof then
		else
			'活动信息收集
			'参加人员
			call cboxmember2("all","",rs("raid_player"))
		end if
	rs.close
end sub

SUB raid_collect2()
	'活动事件添加
	sql="select * from raid where id="&Request("id")
	rs.open sql,conn,1,1
		if rs.eof or rs.bof then exit sub
	dim sdate
	sdate=rs("raid_actiontime")
	rs.close
	'表单
			Response.write "<form name='eventadd' action='admin_eventadd.asp?action=add' method='post'>"
			Response.write "<table class='reportform outframe'>"
			Response.write "<tr><th colspan='6'>添加事件</th></tr>"
			Response.write "<tr class='coltitle'><td>时间</td><td>类型</td><td>对象/描述</td><td>分数</td><td>分数2</td><td></td></tr>"
			Response.write "<tr><td>"&selecteventdate(sdate,"")&"<input type='text' name='event_time' size='14' value='"&hour(sdate)&":"&minute(sdate)&"' /></td><td>"&eventclass("")&"</td> <td>"&raidmemberselect(Request("id"),"")&"<input type='' class='unuse' name='object2' value=''  size='14'/></td>"
			Response.write " <td><input type='text' class='unuse' name='event_dkp' value='' size='6'/></td><td><input type='text' class='unuse' name='event_dkp2' value='' size='6'/></td><td><input type='submit' value='添加'/><input type='hidden' name='postid' value='"&Request("id")&"' /></td></tr>"
			Response.write "</table>"
			Response.write "</form>"	
	'已有事件列表
	if not Isnumeric(Request("id")) then exit sub
	sql="select * from raid_event where event_raidid="&Request("id")&" order by event_time"
	rs.open sql,conn,1,1
		if rs.bof or rs.eof then
		else
			'活动信息收集
			'参加人员
			Response.write "<h4></h4>"
			Response.write "<table class='eventlist outframe interlace hasfocus'>"
			Response.write "<tr><th colspan='7'><div class='title'><img src='images/icon/banner.jpg'>事件列表</div><div class='filter'>[<a href='raid_report.asp?id="&request("id")&"'>查看报告</a>]</div></th></tr>"
			Response.write "<tr class='coltitle'><td>时间</td><td>玩家</td><td>类型</td> <td>对象/描述</td> <td>分数</td><td>拾取分配</td> <td>操作</td></tr>"
			for i = 1 to rs.recordcount
			Response.write "<tr><td>"&rs("event_time")&"</td><td>"&id2name(rs("event_object"))&"</td> <td>"&getEventIco(rs("event_class"))&rs("event_class")&"</td>  <td>"&rs("event_object2")&"</td><td>"&rs("event_dkp")&"</td> <td>"&rs("event_dkp2")&"</td><td><a href='admin_event_edit.asp?id="&rs("id")&"&rid="&Request("id")&"' >修改</a> <a href='admin_eventadd.asp?action=del&id="&rs("id")&"'>删除</a></td></tr>"
			rs.movenext
			next
			Response.write "</table>"
			Response.write "<div class='message'>物品名称后面的""#数字""是物品的ID编号,如果删除将不能读取官方Armory.</div>"
		end if
	rs.close
end sub

SUB raid_collect3()
	'活动信息收集
	'发生事件
end sub

Sub step1sql
	'验证提交数据有效性
	'数据库字段:
	Dim errorinfo
	'if request("raid_name")="" then errorinfo=errorinfo & "<li>活动名称请不要留空.</li>"
	'if not IsDate(request("raid_concentratetime")) then errorinfo=errorinfo & "<li>集结的时间格式不正确,请参考旁边的格式</li>"
	'if not IsDate(request("raid_actiontime")) then errorinfo=errorinfo & "<li>行动的时间格式不正确,请参考旁边的格式</li>"
	'if not IsNumeric(request("raid_personnel")) then errorinfo=errorinfo & "<li>人员数量必须为数字</li>"
	'if request("ruler_name")="" then errorinfo=errorinfo & "<li>请选择一个DKP规则,如果没有请先建立.</li>"
	'if IsValidEmail(request("L_AuthorMail"))<>"true" and request("L_AuthorMail")<>"" then errorinfo=errorinfo & "<li>无效的邮箱地址.</li>"
	'验证///

	if errorinfo<>"" then
		'抛出错误提示
		Response.write "<p>表单信息有误,提示如下:</p><ul>"&errorinfo&"</ul>"
		Response.write "请<a href='"&Url&"'>返回</a>重新修改."
	else
		'写入数据库
		Sql="Select * from raid where id="&Request("postid")
		rs.open sql,conn,1,3
		rs("raid_player")=request("raid_player")
		if rs("raid_step")<>3 then rs("raid_step")=1
		rs.update
		rs.close
		Response.write "<div class='message'><h3>参加人员指定完成</h3><div><a href='"&Url&"' class='abtn2'>继续添加</a> <a href='admin_report.asp?action=collect2&id="&Request("postid")&"' class='abtn3'>编辑活动事件</a> <a href='admin_report.asp' class='abtn3'>查看列表</a> | <a href='raid_report.asp?id="&Request("postid")&"' class='abtn'>查看该活动报告</a>"
		Response.write "</div></div>"

	end if

	'删除
	sql="Delete * from dkplist where raidid="&Request("postid")
	conn.execute (sql)
End sub

function cboxmember(t,m,arr)
	't 职业		m		arr 选中数值序列
	sql="select * from player where player_profession='"&t&"' Order by player_name"
	rs2.open sql,conn,1,1
	dim pcode
	pcode="<ol id='playerlist'><h3>"&t&"</h3>"

		if rs2.bof or rs2.eof then
			pcode=pcode & "<li>没有此职业成员</li>"
		else
			for i = 1 to rs2.recordcount
				pcode=pcode & "<li><input type='checkbox' name='raid_player' value='"&rs2("id")&"' "&memberchecked(rs2("id"),arr)&" />"&rs2("player_name")&"</li>"
			rs2.movenext
			next
		end if
	pcode=pcode & "</ol>"
	cboxmember=pcode
	rs2.close
end function

function prof2style(pro)
	select case pro
		case "战士"
		prof2style="warrior"
		case "牧师"
		prof2style="priest"
		case "法师"
		prof2style="mage"
		case "盗贼"
		prof2style="rogue"
		case "猎人"
		prof2style="hunter"
		case "圣骑士"
		prof2style="paladin"
		case "萨满"
		prof2style="shaman"
		case "术士"
		prof2style="warlock"
		case "德鲁依"
		prof2style="druid"
		case else
		prof2style="unknow"
	end select
end function


Sub cboxmember2(t,m,arr)
	't 职业		m		arr 选中数值序列
	dim procheck
		Response.write "<form action='?action=step1sql' method='post'><table class='playselecttable outframe'><tr>"
			Response.write "<th colspan='10'><input type='submit' value='完成人员指定' /></th></tr><tr>"
	For u = 0 To UBound(ArrTF)
		Response.write "<td><dl><dt>"&ProPic(ArrTF(u)(0))&" "&ArrTF(u)(0)&"</dt>"
		sql="select * from player where player_profession = """&ArrTF(u)(0)&""" order by player_raidnum desc , player_lastraid desc"
		rs2.open sql,conn,1,1
			if rs2.bof or rs2.eof then
				Response.write "没有该职业成员"
			else
				for i = 1 to rs2.recordcount
					Response.write "<dd class='"&memberchecked(rs2("id"),arr)&"'><input type='checkbox' name='raid_player' value='"&rs2("id")&"' "&memberchecked(rs2("id"),arr)&" />"&rs2("player_name")&"</dd>"&vbCrlf
				rs2.movenext
				next
			end if
		rs2.close
		Response.write "</dl></td>"
	Next
			Response.write "</tr><tr><th colspan='10'><input type='hidden' name='postid' value='"&Request("id")&"' /><input type='submit' value='完成人员指定' /></th>"	
		Response.write "</tr></table></form>"
end Sub

SUB raidmemberlist(id)
	't 职业		m		arr 选中数值序列
	sql="select * from player where player_profession='"&t&"' Order by player_name"
	rs2.open sql,conn,1,1
	dim pcode
	pcode="<h4>"&t&"</h4><ul>"

		if rs2.bof or rs2.eof then
			pcode=pcode & "<li>没有此职业成员</li>"
		else
			for i = 1 to rs2.recordcount
				pcode=pcode & "<li><input type='checkbox' name='raid_player' value='"&rs2("id")&"' "&memberchecked(rs2("id"),arr)&" />"&rs2("player_name")&"</li>"
			rs2.movenext
			next
		end if
	pcode=pcode & "</ul>"
	cboxmember=pcode
	rs2.close
end SUb

function memberchecked(id,arr2)
	'找出arr序列中时候包含id ,真则返回"checked"
	dim arr3
	if len(arr2&"w")<2 then 
		exit function
	else
		arr3=split(arr2,",")
		for il= 0 to UBound(arr3)
			if id=int(arr3(il)) then
				memberchecked="checked"
				exit function
			end if
		next
	end if
end function

Sub raid_list()
	response.write "			<table class='adminlist outframe interlace'>"
	response.write "			<tr>"
	response.write "			<th colspan='6'><div class='title'><img src='images/icon/banner.jpg'>活动列表</div><div class='filter'>"&selectraid2()&"</div></th>"
	response.write "			</tr>"
	response.write "			<tr class='coltitle'>"
	response.write "				<td width='29px'>-</td>"
	response.write "				<td>分类</td>"
	response.write "				<td width='40%'>活动</td>"
	response.write "				<td>操作</td>"
	response.write "				<td>时间</td>"
	response.write "				<td>状态</td>"
	response.write "			</tr>"&vbCrlf

		if request.form("filter")<>"" then
			select case true
				case request.form("filter")="all"
					sql="select * from raid Order by raid_actiontime desc"
				case request.form("filter")="edit"
					sql="select * from raid where raid_step<1 or raid_class=0 Order by raid_actiontime desc"
				case request.form("filter")="end"
					sql="select * from raid where raid_step>1 Order by raid_actiontime desc"
				case left(request.form("filter"),1)="D"
					sql="select * from raid where raid_class="&Mid(request.form("filter"),2)&" Order by raid_actiontime desc"
				case left(request.form("filter"),1)="R"
					sql="select * from raid where raid_ruler='"&Mid(request.form("filter"),2)&"' Order by raid_actiontime desc"
			end select
		else
			sql="select * from raid where raid_step<2 Order by raid_actiontime desc"
		end if

	rs.open sql,conn,1,1
		if rs.bof or rs.eof then
			response.write "<tr><td colspan='6' >没有找到链接项</td></tr>"
		else	
			for i = 1 to rs.recordcount
				Response.write "<tr>"
				Response.write "	<td>"&raidPic(rs("raid_name"))&"</td>"
				Response.write "	<td>"&raidclassText(rs("raid_class"))&"</td>"
				Response.write "	<td><h5><a href='raid_report.asp?id="&rs("id")&"'>"&rs("raid_name")&"</a></h5><span>"&rs("raid_plan")&"</span></td>"
				Response.write "	<td>"&opbtn(rs("id"))&"</td>"
				Response.write "	<td>"&rs("raid_actiontime")&"</td>"
				Response.write "	<td>"&oplink(rs("id"))&"</td>"
				Response.write "</tr>"&vbCrlf
			rs.movenext
				if rs.eof then exit for
				next
		end if
	rs.close
'response.write "<tr><td colspan='6' ><a href=''>查看更多活动记录</a></td></tr>"
response.write "</table>"
End Sub

Function opbtn(id)
	sql="select * from raid where id="&id
	rs2.open sql,conn,1,1
	opbtn=""

	opbtn=opbtn&"<span>["
		if rs2("raid_step")>1 then
			opbtn=opbtn&"基本信息"
		else
			opbtn=opbtn&"<a href='admin_raid.asp?action=edit&id="&id&"'>基本信息</a>"
		end if

		if rs2("raid_step")>1 then
			opbtn=opbtn&"-参加人员"
		else
			opbtn=opbtn&"-<a href='?action=collect&id="&id&"'>参加人员</a>"
		end if
		if rs2("raid_step")>1 or rs2("raid_step")=0 then
			opbtn=opbtn&"-活动事件]"
		else
			opbtn=opbtn&"-<a href='?action=collect2&id="&id&"'>活动事件</a>]"
		end if
		if rs2("raid_step")<1 then
			opbtn=opbtn&"-查看报告"
		else
			opbtn=opbtn&"-<a href='raid_report.asp?id="&id&"' class='abtn'>查看报告</a>"
		end if
		if Session(ULVL)<2 then
			if rs2("raid_step")>1 then
				opbtn=opbtn&"-[归档"
			else
				opbtn=opbtn&"-[<a href='raid_end.asp?id="&id&"' class='abtn3'>归档</a>"
			end if

			if Session(ULVL)=0 then opbtn=opbtn&"-<a href ='admin_raid.asp?action=del&id="&rs("id")&"' onclick=""javascript:return(confirm('确定要删除这个活动吗？'))"" class='abtn4'>删</a>"
			opbtn=opbtn&"]"
		end if
	opbtn=opbtn&"</span>"
	rs2.close
End function


Function oplink(id)
	dim optext
	if not IsNumeric(id) then exit Function
	sql="select * from raid where id="&id
	rs2.open sql,conn,1,1
		if rs2("raid_player")="" or rs2("raid_step")=0 then optext=optext&"<li>未添加人员信息</li>"
		if rs2("raid_step")=0 then optext=optext&"<li>未添加活动事件</li>"
		if rs2("raid_step")>1 then optext=optext&"<li>已归档,只可查看报告</li>"
		if rs2("raid_class")=0 or rs2("raid_class")="" then optext=optext&"<li>活动未设置DKP分类</li>"
	rs2.close
	if optext<>"" then
	oplink="<ul class='status'>"&optext&"</ul>"
	end if
End Function


Function oplink2(id)
	dim step1
	step1="<a href='?action=collect&id="&id&"'>人员</a> - <a href='?action=collect2&id="&id&"'>事件</a> - <a href='raid_report.asp?id="&id&"'>报告</a>"
	if not IsNumeric(id) then exit Function
	sql="select * from raid where id="&id
	rs2.open sql,conn,1,1
	if rs.bof or rs.eof then
	else
		select case true
			case rs2("raid_step")=1

			case rs2("raid_step")=0

			case rs2("raid_step")>1
		end select







		if rs2("raid_step")=1 then 	
			step1="<a href='?action=collect&id="&id&"'>人员</a> - <a href='?action=collect2&id="&id&"'>事件</a> - <a href='raid_report.asp?id="&id&"'>报告</a>"
		elseif rs2("raid_step")=0 then
			step1="<a href='?action=collect&id="&id&"'>人员</a> - 事件 - 报告"
		elseif rs2("raid_step")>1 then
			step1="人员 - 事件 - <a href='raid_report.asp?id="&id&"'>报告</a>"
		end if
	end if

	if rs2("raid_step")>1 then
	oplink="[ " & step1 & " ]<br/>" & "[ 修改 - <a href='admin_raid.asp?action=del&id="&rs("id")&"'>删除</a> - 已归档 ]"
	else
	oplink="[ " & step1 & " ]<br/>" & "[ <a href='admin_raid.asp?action=edit&id="&rs("id")&"'>修改</a> - <a href='admin_raid.asp?action=del&id="&rs("id")&"'>删除</a> - <a href='raid_end.asp?id="&id&"'>归档</a> ]"
	end if
	rs2.close
End Function




%>